package com.xinzhi.controller;

import com.alibaba.fastjson.JSONObject;
import com.xinzhi.service.ailyunService.IAlilDService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class AlilDController {
    @Autowired
    private IAlilDService alilDService;

    /**
     * OCR身份证识别
     * @param file 身份证图片路径
     * @return
     */
    @PostMapping(value = "/ocr/idcard", consumes = "multipart/form-data")
    public JSONObject ocrIdCard(@RequestParam("file") MultipartFile file){
        return alilDService.ocrIdCard(file);
    }

    /**
     * 识别身份信息
     * @param idcard 身份证号
     * @param name 姓名
     * @return
     */
    @GetMapping("/check/idcard")
    public JSONObject checkIdcard(@RequestParam("idcard") String idcard,@RequestParam("name") String name) {
        return alilDService.checkIdcard(idcard, name);
    }
}
